package 算法语言基础.Day12_7.通讯录;



import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class Initialization extends JFrame implements ActionListener{

    JLayeredPane backgroundjpl;
    JPanel jplNorth,jplCenter,jplbackground;
    JButton jbt1,jbt2;
    JLabel jlb,jlb1,jlb2;
    ImageIcon backgroungimage,insertimage;

    Initialization(String str){
        super(str);

        jlb1 = new JLabel("欢迎使用同学通讯录");
        backgroundjpl = new JLayeredPane();
        backgroungimage = new ImageIcon("image/background.jpg");
        insertimage = new ImageIcon("image/cover.png");
        jplbackground = new JPanel();
        jplNorth = new JPanel();
        jplCenter = new JPanel();
        jbt1 = new JButton("进入");
        jbt1.addActionListener(this);
        jbt2 = new JButton("退出");
        jbt2.addActionListener(this);
        jlb = new JLabel(backgroungimage);
        jlb2 = new JLabel(insertimage);

        jplbackground.setSize(backgroungimage.getIconWidth(),backgroungimage.getIconHeight());
        jlb.setSize(backgroungimage.getIconWidth(),backgroungimage.getIconHeight());
        jplbackground.add(jlb);

        jplCenter.setSize(insertimage.getIconWidth(),insertimage.getIconHeight());
        jlb2.setSize(insertimage.getIconWidth(),insertimage.getIconHeight());
        jplCenter.add(jlb2);

        Font f = new Font("宋体",1,60);
        Font f1 = new Font("楷体",1,80);
        jbt1.setFont(f);
        jbt1.setBackground(new Color(242,233,202));
        jbt2.setFont(f);
        jbt2.setBackground(new Color(242,233,202));
        jlb1.setFont(f1);

        jbt1.setBounds(100,200,200,80);
        jbt2.setBounds(100,300,200,80);
        jplCenter.setBounds(670,350,insertimage.getIconWidth(),insertimage.getIconHeight());
        jplNorth.add(jlb1);
        jplNorth.setBackground(new Color(244,237,209));
        jplNorth.setBounds(420,100,800,200);

        backgroundjpl.add(jplbackground,JLayeredPane.DEFAULT_LAYER);
        backgroundjpl.add(jplNorth,JLayeredPane.MODAL_LAYER);
        backgroundjpl.add(jplCenter,JLayeredPane.MODAL_LAYER);
        backgroundjpl.add(jbt1,JLayeredPane.MODAL_LAYER);
        backgroundjpl.add(jbt2,JLayeredPane.MODAL_LAYER);
        this.pack();
        this.setLayeredPane(backgroundjpl);
        this.setBounds(700,500,backgroungimage.getIconWidth(),backgroungimage.getIconHeight());
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand()=="退出")
        {
            System.exit(0);
        }
        else if(e.getActionCommand()=="进入")
        {
            this.dispose();  //关闭当前界面
            Features F=new Features("功能界面");   //打开新界面
            F.setLocationRelativeTo(null);
        }
    }

    public static void main(String[] args) {
        Initialization Correspondence_address = new Initialization("同学通讯录");
        Correspondence_address.setLocationRelativeTo(null);
    }
}
